<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>完善当当购物车页面</title>
    <link type="text/css" rel="stylesheet" href="css/cartStyle.css" />
    <script type="text/javascript">
    	function add(no){
    		var num=document.getElementsByName("amount")[no];
    		num.value++;
    	}
    	function cut(no){
    		var num=document.getElementsByName("amount")[no];
    		if(num.value==0){
    			alert("不能在减了")
    		}
    		else{
    			num.value--;
    		}
    	}
    	function buy(){
    		var nums=document.getElementsByName("amount");
    		var price=document.getElementsByName("price");
    		var sum=0;
    		for(var i=0;i<nums.length;i++){
    			sum+=nums[i].value*price[i].value;
    		}
    		document.getElementById("totalPrice").innerHTML=sum;
    	}
    </script>
</head>
<body>

<div class="content">
    <div class="logo">
        <img src="images/dd_logo.jpg"><span>关闭</span>
    </div>
    <div class="cartList">
        <ul>
            <li>¥<input type="text" name="price" value="21.90"></li>
            <li><input type="button" name="minus" value="-" onclick="cut(0)"><input type="text" name="amount" value="1"><input type="button" name="plus" value="+" onclick="add(0)"></li>
            <li id="price0">¥21.90</li>
            <li><p>移入收藏</p><p>删除</p></li>
        </ul>
        <ul>
            <li>¥<input type="text" name="price" value="24.00"></li>
            <li><input type="button" name="minus" value="-" onclick="cut(1)"><input type="text" name="amount" value="1"><input type="button" name="plus" value="+" onclick="add(1)"></li>
            <li id="price1">¥24.00</li>
            <li><p>移入收藏</p><p>删除</p></li>
        </ul>
        <ol>
            <li id="totalPrice">&nbsp;</li>
            <li><span onclick="buy()">结 算</span></li>
        </ol>
    </div>
</div>
</body>
</html>